# Create your views here.
from django.http import JsonResponse

from risk.models import *
from risk.serializers import *
from dvadmin.utils.viewset import CustomModelViewSet


class ZhaohuiViewSet(CustomModelViewSet):
    """
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = Zhaohui.objects.all()
    serializer_class = ZhaohuiSerializer
    create_serializer_class = ZhaohuiCreateUpdateSerializer
    update_serializer_class = ZhaohuiCreateUpdateSerializer
    filter_fields = ["产品分类_月报_field", "日期", "召回数量", "产品名称", "标题", "召回原因", "危害源", "危害情况", "区域", "链接"]
    search_fields = ["产品分类_月报_field", "日期", "召回数量", "产品名称", "标题", "召回原因", "危害源", "危害情况", "区域", "链接"]

    def get_present_data(self, request, *args, **kwargs):
        response = {"data": {}}



        response |= {
            "code": 2000,
            "msg": "success"
        }

        return JsonResponse(response)
